/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#pragma once

#include "..\..\XInput\Input.h"
#include "GameScreenManagerComponent.h"
#include "..\XOgre\OgreRenderer.h"
#include "..\..\XMessaging\Messenger.h"

namespace XF
{
	namespace ScreenState
	{
		enum ENUM
		{
			SCREEN_TRANSITION_ON,
			SCREEN_ACTIVE,
			SCREEN_TRANSITION_OFF,
			SCREEN_NOT_ACTIVE,
		};
	}

	class GameScreen : public Messenger
	{
	private:
		bool mKillScreen;
		bool mIsPopup;

		ScreenState::ENUM mScreenState;
		float mScreenLifeTime, mTransitionTimer;

	protected:
		virtual bool OnInitialise() = 0; //chris i modified these to be bools
		virtual void OnHandleInput(double dT, Input *input) = 0;
		virtual void OnUpdate(double dT) = 0;
		virtual void OnShutDown() = 0;
		
		virtual void OnScreenJustWentActive(){}
		virtual void OnScreenJustWentInActive(){}

		virtual void OnShowScreen(){}
		virtual void OnHideScreen(){}

		float mTransitionOnTime, mTransitionOffTime;
		OgreRenderer *mRenderer;
		GameScreenManagerComponent *mScreenManager;

	public:
		GameScreen(bool isPopup);
		virtual ~GameScreen();

		OgreRenderer *GetRenderer(){return mRenderer;}
		bool Initialise(GameScreenManagerComponent *screenManager);
		void HandleInput(double dT, Input *input);
		void Update(double dT);
		void Shutdown();

		void ExitScreen(){ mKillScreen = true; TransitionOff();}
		bool ScreenWantsToExit(){ return mKillScreen; }

		bool IsPopup(){ return mIsPopup; }

		ScreenState::ENUM GetScreenState(){return mScreenState;}

		void TransitionOn();
		void TransitionOff();

		float TransitionDelta();
		float ScreenLifetime(){return mScreenLifeTime;}

		GameScreenManagerComponent* ScreenManager(){return mScreenManager;}
	};
}
